﻿@using VirtualPress.Infrastructure.Entities.Entity;
@using VirtualPress.Infrastructure.Entities.Enum;
@{
    Periodical journal = ViewBag.Journal;
    ViewBag.Title = "期刊出版 -- "+journal.Name;
    Layout = "/Areas/WorkSpace/Views/Shared/_WorkSpace.cshtml";
}
<div id="content-header">
    <h1>
        期刊出版</h1>
</div>
<div id="breadcrumb">
    <a href="/WorkSpace/console/index" class="tip-bottom"><i class="icon-home"></i>起始页</a> <a href="javascript:"
        class="current">期刊出版</a>
</div>
<div class="container-fluid">
    <div class="row-fluid">
        <div class="span12">
            <div class="widget-box" style="margin-top: 0px;">
                <div class="widget-title">
                    <span class="icon"><i class="icon-file"></i></span>
                    <h5>
                        期刊出版</h5>
                    <div class="buttons" style="margin-right: 15px;">
                        <a href="/workspace/console/newpublish" class="btn btn-success btn-mini"><i class="icon-plus icon-white">
                        </i>新增期</a>
                    </div>
                </div>
                <div class="widget-content nopadding">
                    <div class="widget-box">
                        <div class="widget-content nopadding">
                            <ul class="recent-posts">
                                @{
                                    ItemListBox<PeriodicalItem> data = ViewBag.Data;
                                    if (data != null && data.Data != null)
                                    {
                                        foreach (var item in data.Data)
                                        {
                                    <li>
                                        <div class="user-thumb">
                                            <img style="width:40px; height:40px;" alt="journal" src="@journal.CoverImg">
                                        </div>
                                        <div class="article-post">
                                            <span class="user-info">第 @item.Manuscriptcode 期 
                                            @if(item.Status == JournalItemStatus.Create){
                                                <font style="color: Orange; font-weight: bold;">[筹备中]</font>
                                                 <p>
                                                    已选定 @item.Articles.Count 篇稿件
                                                </p>
                                            }
                                            else
                                            {
                                                <font style="color: Green; font-weight: bold;">[已出版]</font>
                                                 <p>
                                                    共包含 @item.Articles.Count 篇稿件
                                                </p>
                                            }   
                                            </span>
                                            @if(item.Status == JournalItemStatus.Create)
                                            {
                                                <a href="/workspace/console/articlebank?publish=@item.Id" class="btn btn-primary btn-mini">添加稿件</a> 
                                            }
                                            <a href="javascript:;" onclick="showdetail(this)" class="btn btn-primary btn-mini">查看</a> 
                                            @if(item.Status == JournalItemStatus.Create)
                                            {
                                                <a href="javascript:;" onclick="publish(@item.Id,@item.Articles.Count)" class="btn btn-success btn-mini">确定出版</a> 
                                                <a href="javascript:;" onclick="deletejournalitem(@item.Id)"
                                                        class="btn btn-danger btn-mini">删除</a>
                                            }
                                        </div>
                                        <div style="display: none;">
                                            <ul>
                                            @if(item.Articles!=null && item.Articles.Any())
                                            {
                                                foreach(var article in item.Articles)
                                                {
                                                    <li><a href="javascript:;">@article.Title</a></li>
                                                }
                                            }
                                            else
                                            {
                                                <li>不包含任何稿件</li>
                                            }
                                            </ul>
                                        </div>
                                    </li>
                                        }
                                    }
                                }
                            </ul>
                        </div>
                    </div>
                </div>
                @Html.Raw(data.PageItemSegment)
            </div>
        </div>
    </div>
</div>
@section tail{
    <script type="text/javascript">
        $(function () {
            $('#likpublish').addClass('open active');
        });
        function showdetail(sender) {
            $(sender).parent().next('div').toggle();
        }
        function deletejournalitem(id) {
            if (confirm('您确定删除此期吗？')) {
                window.location.href = '/workspace/console/deletejournalItem?journalItemId=' + id;
            }
        }
        function publish(id,count) {
            if (confirm('您确定要出版此期吗？此期一共选定：' + count + " 篇稿件")) {
                window.location.href = '/workspace/console/publishjournalItem?journalItemId=' + id;
            }
        }
    </script>
}
